package sanger;

import com.amazonaws.auth.PropertiesCredentials;
import com.amazonaws.services.s3.AmazonS3Client;
import com.amazonaws.services.ec2.AmazonEC2Client;
import java.io.FileNotFoundException;
import java.io.IOException;

public class Constants {

    public static final String UPLOAD_DIR = "/root/velvet_1.1.04/uploads"; //trailing '/' not required
    public static final String REMOTE_UPLOAD_DIR = "/home/ec2-user/uploads";
    public static final String REMOTE_APP_DIR = "/home/ec2-user/script";
    public static final String PRIVATE_KEY = "/root/nib9key.pem";
    public static final String USER_FILE = "/root/aws/users.txt";
    private static AmazonS3Client s3ref = null; //init on first use
    private static AmazonEC2Client ec2ref = null;

    //Amazon singleton
    public static AmazonS3Client getS3Obj() throws FileNotFoundException, IOException {
        if (s3ref == null) {
            s3ref = new AmazonS3Client(new PropertiesCredentials(
                    Constants.class.getResourceAsStream("AwsCredentials.properties")));
            //return s3ref;
        }

        return s3ref;

    }

    public static AmazonEC2Client getEC2Obj() throws IOException {
        if (ec2ref == null) {
            ec2ref = new AmazonEC2Client(new PropertiesCredentials(
                    Constants.class.getResourceAsStream("AwsCredentials.properties")));
        }

        return ec2ref;
    }
}
